package com.globalwave.common.service;

import java.sql.Connection;

import com.globalwave.base.BaseServiceImpl;
import com.globalwave.common.ArrayOrderList;
import com.globalwave.common.ArrayPageList;
import com.globalwave.common.db.SimpleJDBCDAO;
import com.globalwave.common.entity.SyncRecordBackup;
import com.globalwave.common.entity.SyncRecordBackupCriterion;

public class SyncRecordBackupServiceImpl 
       extends BaseServiceImpl 
       implements SyncRecordBackupService {
	
	public SyncRecordBackupServiceImpl(Connection connection) {
		this.jdbcDao = new SimpleJDBCDAO() ;
		this.jdbcDao.setConnection(connection) ;
	}
    public SyncRecordBackup create(SyncRecordBackup syncRecordBackup) throws Exception {
        return (SyncRecordBackup) jdbcDao.insert(syncRecordBackup);
    }

    public void update(SyncRecordBackup syncRecordBackup) throws Exception {
        jdbcDao.update(syncRecordBackup) ;
    }

    public void delete(SyncRecordBackup syncRecordBackup) throws Exception {
        // delete cascade 
        //OrganizationSyncRecordBackup orgSyncRecordBackup = new OrganizationSyncRecordBackup() ;
        //orgSyncRecordBackup.setSyncRecordBackup_id(syncRecordBackup.getSyncRecordBackup_id()) ;
        //jdbcDao.delete(OrganizationSyncRecordBackup.class, orgSyncRecordBackup) ;
        
        jdbcDao.delete(syncRecordBackup) ;
        
    }

    public void deleteAll(Long[] ids) throws Exception {
        SyncRecordBackupCriterion criterion = new SyncRecordBackupCriterion() ;
        criterion.setIds(ids) ;
        jdbcDao.delete(SyncRecordBackup.class, criterion) ;
        
    }

    public ArrayPageList<SyncRecordBackup> query(
            SyncRecordBackupCriterion criterion, 
            int pageIndex, 
            int pageSize, 
            ArrayOrderList orderList) throws Exception {
        
        if (orderList == null) {
            orderList = new ArrayOrderList() ;
            //orderList.addAsc("syncRecordBackup_id") ;
        }
        
        return (ArrayPageList<SyncRecordBackup>)jdbcDao.query(criterion, pageIndex, pageSize, orderList, SyncRecordBackup.class);
    }


    
}
